package com.wuxf.service;

import java.util.HashMap;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wuxf.entity.ConsumeInfo;
import com.wuxf.entity.PwdInfo;
import com.wuxf.entity.custom.ConsumeCustom;
import com.wuxf.mapper.custom.ConsumeMapper;
import com.wuxf.mapper.custom.InvoiceMapper;
import com.wuxf.mapper.custom.PwdMapper;
import com.wuxf.util.DateUtils;

@Service
@SuppressWarnings({"rawtypes"})
public class ConsumeService {
	@Autowired
	ConsumeMapper consumeMapper;
	@Autowired
	private PwdMapper pwdMapper;
	
	@Autowired
	private InvoiceMapper invoiceMapper;
	public List<ConsumeInfo> findTotal(HashMap paraMap){
		return invoiceMapper.findByTotal(paraMap);
	}
	
	public List<ConsumeCustom> findByGroupSynthesis(HashMap paraMap){
		return consumeMapper.findByGroupSynthesis(paraMap);
	}
	
	public List<ConsumeCustom> findByMapGroupArea(HashMap paraMap){
		return consumeMapper.findByMapGroupArea(paraMap);
	}
	public List<ConsumeCustom> findByMapGroupType(HashMap paraMap){
		return consumeMapper.findByMapGroupType(paraMap);
	}
	public List<ConsumeCustom> findByMapGroupUnit(HashMap paraMap){
		return consumeMapper.findByMapGroupUnit(paraMap);
	}
	
	
	public PageInfo<List<ConsumeCustom>> findByPageGroupSynthesis(HashMap paraMap,PageInfo pageInfo){
		PageHelper.startPage(pageInfo.getPageNum(), pageInfo.getPageSize());
		return new PageInfo(consumeMapper.findByGroupSynthesis(paraMap));
	}
	
	public PageInfo<List<ConsumeCustom>> findByPageGroupArea(HashMap paraMap,PageInfo pageInfo){
		PageHelper.startPage(pageInfo.getPageNum(), pageInfo.getPageSize());
		return  new PageInfo(consumeMapper.findByMapGroupArea(paraMap));
	}
	
	public PageInfo<List<ConsumeCustom>> findByPageGroupCarno(HashMap paraMap,PageInfo pageInfo){
		PageHelper.startPage(pageInfo.getPageNum(), pageInfo.getPageSize());
		return new PageInfo(consumeMapper.findByMapGroupCarno(paraMap));
	}
	
	
	public List<ConsumeCustom> findByPageGroupType(HashMap paraMap,PageInfo pageInfo){
		PageHelper.startPage(pageInfo.getPageNum(), pageInfo.getPageSize());
		return consumeMapper.findByMapGroupType(paraMap);
	}
	public PageInfo<List<ConsumeCustom>> findByPageGroupUnit(HashMap paraMap,PageInfo pageInfo){
		PageHelper.startPage(pageInfo.getPageNum(), pageInfo.getPageSize());
		return new PageInfo(consumeMapper.findByMapGroupUnit(paraMap));
	}
	
	public void saveConsume(ConsumeInfo consumeInfo,PwdInfo pwdInfo){
		pwdInfo.setState("2");
		pwdInfo.setUpdateTime(DateUtils.getNowDate());
		pwdMapper.updatePwdInfo(pwdInfo);
		consumeInfo.setCreateTime(DateUtils.getNowDate());
		consumeInfo.setUpdateTime(DateUtils.getNowDate());
		consumeMapper.saveConsume(consumeInfo);
	}
	
	public List<ConsumeCustom> findByMap(HashMap paraMap){
		return consumeMapper.findByMap(paraMap);
	}
	
	public PageInfo<List<ConsumeCustom>> findByMapAndPage(HashMap paraMap,PageInfo pageInfo){
		PageHelper.startPage(pageInfo.getPageNum(), pageInfo.getPageSize());
		return  new PageInfo(consumeMapper.findByMap(paraMap));
	}
	
}
